﻿//​你只需要写出Matrix类即可，主函数已给出//除主函数定义的方法名及参数名外，其余名称或方法可自行添加或修改

#include<iostream>
#include<string>
using namespace std;
class Matrix {
private:
    /*int** p;*/
    int p[3][3];
public:
    /*Matrix()
    {
        p = new int*[3];
        int i = 0;
        for (i = 0; i < 3; i++)
        {
            p[i] = new int[3];
        }
    }*/
    void setMatrix() {
        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; j++)
            {
                int a;
                cin >> a;
                p[i][j]=a;
            }
        }
    }
    Matrix mutipleMatrix(Matrix b)
    {
       
        Matrix t;
        int i = 0;
        int j = 0;
        int k=0;
        for (i = 0;i< 3; i++)
        {
            for (j = 0; j < 3; j++)
            { int sum=0;
                for (k = 0; k < 3; k++)
                {
                    sum += this->p[i][k] * b.p[k][j];
                }
                t.p[i][j] = sum;
            }
        }return t;
    }
    void printMatrix()
    {
        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; j++)
            {

                cout << p[i][j]<<" ";
            }cout << endl;
        }
    }
};

int main()
{
    Matrix a, b, c;
    a.setMatrix();
    b.setMatrix();
    c = a.mutipleMatrix(b);
    c.printMatrix();
    return 0;
}